<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=utf-8"%>
<!doctype html>

<html class="no-js">
<style>
.am-tabs-nav li {
	position: relative;
	z-index: 1;
}

.am-tabs-nav .am-icon-close {
	position: absolute;
	top: 0;
	right: 10px;
	color: #888;
	cursor: pointer;
	z-index: 100;
}

.am-tabs-nav .am-icon-close:hover {
	color: #333;
}

.am-tabs-nav .am-icon-close ~ a {
	padding-right: 25px !important;
}
</style>
<head>
<%@ include file="../commoms/link.txt"%>
<meta name="description" content="ReqManager">
<script type="text/javascript" src="assets/js/pagejs/ReqManager.js"></script>
</head>
<body>
	<%@ include file="../commoms/ERHeader.txt"%>

	<div class="admin-content">
		<div class="admin-content-body">
			<div class="am-g">

				<div class="am-tabs" data-am-tabs="{noSwipe: 1}" id="doc-tab-demo-1">
					<ul class="am-tabs-nav am-nav am-nav-tabs" id="ops">
						<li class="am-active"><a href="javascript: void(0)"
							class="tabdiff" id="tabdiff0">未同意</a></li>
						<li><a href="javascript: void(0)" class="tabdiff"
							id="tabdiff1">已同意</a></li>
						<li><a href="javascript: void(0)" class="tabdiff"
							id="tabdiff2">已拒绝</a></li>

					</ul>

					<div class="am-tabs-bd">




						<div class="am-tab-panel am-active" id="tab0" style="height: 100%">

							<div class="am-g">
								<div class="am-u-sm-12 am-u-md-6">
									<div class="am-btn-toolbar">
										<div class="am-btn-group am-btn-group-xs">
											<button type="button" id='batchagree'
												class="am-btn am-btn-default">
												<span class="am-icon-plus"></span>同意
											</button>
											<button type="button" id="batchdisagree"
												class="am-btn am-btn-default">
												<span class="am-icon-archive"></span> 不同意
											</button>
										</div>
									</div>
								</div>
							</div>
							<div class="am-g">
								<div class="am-u-sm-12">
									<table
										class="am-table am-table-striped am-table-hover table-main reqtable">
										<thead>
											<tr>
												<th class="table-check"><input type="checkbox"
													id="checkall0" /></th>
												<th class="table-id">ID</th>
												<th class="table-title">姓名</th>
												<th class="table-type">性别</th>
												<th class="table-author am-hide-sm-only">年龄</th>
												<th class="table-author am-hide-sm-only">学校</th>
												<th class="table-date am-hide-sm-only">报名时间</th>
												<th class="table-set">操作</th>
											</tr>
										</thead>

										<tbody id="pagecontainer0">

										</tbody>
									</table>

									<div class="am-fr">
										<ul id="page0" data-am-widget="pagination"
											class="am-pagination am-pagination-default">
										</ul>
									</div>

								</div>

							</div>



						</div>
						<div class="am-tab-panel am-active" id="tab1" style="height: 100%">




							<div class="am-g">
								<div class="am-u-sm-12">
									<table
										class="am-table am-table-striped am-table-hover table-main reqtable">
										<thead>
											<tr>

												<th class="table-id">ID</th>
												<th class="table-title">姓名</th>
												<th class="table-type">性别</th>
												<th class="table-author am-hide-sm-only">年龄</th>
												<th class="table-author am-hide-sm-only">联系电话</th>
												<th class="table-author am-hide-sm-only">邮箱</th>
												<th class="table-author am-hide-sm-only">学校</th>
												<th class="table-date am-hide-sm-only">报名时间</th>

											</tr>
										</thead>

										<tbody id="pagecontainer1">

										</tbody>
									</table>

									<div class="am-fr">
										<ul id="page1" data-am-widget="pagination"
											class="am-pagination am-pagination-default">
										</ul>
									</div>

								</div>

							</div>



						</div>
						<div class="am-tab-panel am-active" id="tab2" style="height: 100%">




							<div class="am-g">
								<div class="am-u-sm-12">
									<table
										class="am-table am-table-striped am-table-hover table-main reqtable">
										<thead>
											<tr>
												<th class="table-id">ID</th>
												<th class="table-title">姓名</th>
												<th class="table-type">性别</th>
												<th class="table-author am-hide-sm-only">年龄</th>
												<th class="table-author am-hide-sm-only">联系电话</th>
												<th class="table-author am-hide-sm-only">邮箱</th>
												<th class="table-author am-hide-sm-only">学校</th>
												<th class="table-date am-hide-sm-only">报名时间</th>
											</tr>
										</thead>

										<tbody id="pagecontainer2">

										</tbody>
									</table>

									<div class="am-fr">
										<ul id="page2" data-am-widget="pagination"
											class="am-pagination am-pagination-default">
										</ul>
									</div>

								</div>

							</div>
						</div>
					</div>
				</div>

			</div>
		</div>
	</div>
	<div class="am-popup" id="my-popup">
		<div class="am-popup-inner">
			<div class="am-popup-hd">
				<h4 class="am-popup-title">人员信息</h4>

				<span data-am-modal-close class="am-close">&times;</span>
			</div>
			<div class="am-popup-bd"></div>
		</div>
	</div>
	<%@ include file="../commoms/alert.txt"%>
	<%@ include file="../commoms/comfirmModel.txt"%>
	</div>

	<a href="#"
		class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu"
		data-am-offcanvas="{target: '#admin-offcanvas'}"></a>


	<%
		String ptjobid = request.getParameter("ptjobid");
		String personnum = request.getParameter("neednum");
		String jobstatus = request.getParameter("jobstatus");
		if (ptjobid != null) {
	%>
	<script type="text/javascript">
		var currentpage = 1;
		var pages = 1;
		var personnum =
	<%=personnum%>
		var jobstatus =
	<%=jobstatus%>
		var ptjobid =
	<%=ptjobid%>
		var $ul = $('#page0');
		var $pagecontainer = $('#pagecontainer0');
		var ldata = null;
		var currenttab = 1;
		var status = 30;

		myAjax(domain + "/getAllERCount.do", {}, function(data) {
			$('#count1').text(data.nostart);
			$('#count2').text(data.started + data.end);
			$('#count3').text(data.finish);

		});
		changetabs(0);
		var $modal = $('#my-popup');
		$('#ops').on('click', '.tabdiff', function(event) {
			var temp = event.currentTarget.id.replace("tabdiff", "");
			changetabs(temp);

		});

		$pagecontainer.on('click', '.agreereq', function(event) {
			further('agreereq', event.currentTarget.id)
		});
		$pagecontainer.on('click', '.disagreereq', function(event) {
			further('disagreereq', event.currentTarget.id)
		});
		$pagecontainer.on('click', '.userdetail', function(event) {
			var pid = event.currentTarget.id;
			var index = pid.replace('itemline', "");
			$modal.modal('toggle');
			drawmodal($('#my-popup'), ldata[index]);
		});

		$('#contains').on(
				'click',
				'.itemline',
				function(event) {
					var pid = event.currentTarget.id;
					if (event.target.nodeName != 'BUTTON'
							&& event.target.nodeName != 'SPAN'
							&& event.target.nodeName != 'A'
							&& event.target.nodeName != 'LI'
							&& event.target.nodeName != 'INPUT') {
						var index = pid.replace('itemline', "");

						$modal.modal('toggle');
						drawmodal($('#my-popup'), ldata[index]);
					}
				});

		function opFunction(url, data) {
			myAjax(url, data, function(msg) {
				myPost(domain + '/ReqManager.jsp', {
					'jobstatus':personnum,
					'ptjobid' : ptjobid,
					'neednum' : personnum
				});
			});
		}

		function changepage(a) {
			if (a.innerHTML === '第一页')
				currentpage = 1;
			else if (a.innerHTML === '最末页')
				currentpage = pages;
			else if (a.innerHTML === '上一页')
				currentpage -= 1;
			else if (a.innerHTML === '下一页')
				currentpage += 1;
			else
				currentpage = a.innerHTML;
			$ul.empty();
			drawPages($ul, currentpage, pages, 10);
			$pagecontainer.empty();
			getdiffrequsercontent(domain + '/getReqUser.do', {
				'page' : currentpage,
				'ptjobid' : ptjobid,
				'status' : status
			}, $pagecontainer);
			return false;
		}

		function init() {

			myAjax(domain + "/getReqUserCount.do", {
				'ptjobid' : ptjobid,
				'status' : status
			}, function(data) {
				pages = data['CountNums'];

				pages = Math.ceil(pages / 5)
				if (data['CountNums'] != 0) {
					drawPages($ul, currentpage, pages, 10);
					getdiffrequsercontent(domain + '/getReqUser.do', {
						'page' : currentpage,
						'ptjobid' : ptjobid,
						'status' : status
					}, $pagecontainer);
				}
			});

		}
		$("#checkall0").change(function() {
			if ($("#checkall0").prop('checked'))
				$(".check").prop("checked", "checked");
			else
				$(".check").prop("checked", false);

		});
		$pagecontainer.on('click', '.check', function(event) {

			if (!$('#' + event.currentTarget.id).is(':checked'))
				$("#checkall0").prop("checked", false);
		});

		$("#batchagree").click(function() {
			var id = '?';
			$.each(ldata, function(i, item) {
				if ($('#check' + i).is(':checked'))
					id += 'id=' + item.id + '&';

			});

			if (id != '?') {
				id = id.substring(0, id.length - 1);
				myAjax('/batching/pass.do' + id, {}, function(data) {
					myPost(domain + '/ReqManager.jsp', {
						'jobstatus':personnum,
						'ptjobid' : ptjobid,
						'neednum' : personnum
					});
				});
			} else
				myAlert('提示', '请选择操作的工作');
		});

		$("#batchdisagree").click(function() {
			var id = '?';

			$.each(ldata, function(i, item) {
				if ($('#check' + i).is(':checked'))
					id += 'id=' + item.id + '&';
			});

			if (id != '?') {
				id = id.substring(0, id.length - 1);
				myAjax('/batching/fail.do' + id, {}, function(data) {
					myPost(domain + '/ReqManager.jsp', {
						'jobstatus':personnum,
						'ptjobid' : ptjobid,
						'neednum' : personnum
					});

				});
			} else
				myAlert('提示', '请选择操作的工作');
		});
		var $confirm = myConfirm('提示', '人员数目已满，是否结束报名', function() {

			myAjax('/changeJobStatus.do', {
				'ptid' : ptjobid,
				status : 40
			}, function(data) {
				if (data.state == 'success') {
					myAlert('提示', '结束成功!!!');
					window.location.href = 'JobWorking.jsp';
				} else
					myAlert('提示', '结束失败!!!');

			})
		}, function() {

		});
	</script>

	<%
		}
	%>

</body>
</html>
